#include "isOS.h"
#include "os_cfg.h"

#ifndef __OS_QUE_H__
#define __OS_QUE_H__

#if (OS_QUE_EN==1)

#ifdef __cplusplus
extern "C" {
#endif

//----- Data queue -------------

typedef struct _isOS_QUE
{
   LIST_QUE  wait_send_list;
   LIST_QUE  wait_receive_list;

   isOS_U8 *data_fifo; //-- Array of isOS_U8 * to store data queue entries
   isOS_S16  num_entries;  //-- Capacity of data_fifo(num entries)
   isOS_U16  entry_size;   //-- The size of each items that the queue will hold.
   isOS_U16  tail_cnt;     //-- Counter to processing data queue's Array of void*, for read
   isOS_U16  header_cnt;   //-- Counter to processing data queue's Array of void*, for write
   isOS_S32  id_dque;      //-- ID for verification(is it a data queue or another object?)
                        // All data queues have the same id_dque magic number (ver 2.x)
}isOS_QUE;


/* For internal use only. */
#define	queueSEND_TO_BACK	( 0 )
#define	queueSEND_TO_FRONT	( 1 )


/*
 * Utilities to query queue that are safe to use from an ISR.  These utilities
 * should be used only from witin an ISR, or within a critical section.
 */
isOS_S32 isOS_QueueIsEmpty( const isOS_QUE * dque );
isOS_S32 isOS_QueueIsFull( const isOS_QUE * dque );



isOS_S32 isOS_QueueCreate(isOS_QUE * dque,
                      isOS_U8* data_fifo,
                      isOS_S16 num_entries,
					  isOS_U16 entry_size
                      );
isOS_S32 isOS_QueueDelete(isOS_QUE * dque);  //-- v.2.0
isOS_S32 isOS_QueueSend(isOS_QUE * dque,void * data_ptr,isOS_U32 timeout);
isOS_S32 isOS_QueueReceive(isOS_QUE * dque,void * data_ptr,isOS_U32 timeout);

#ifdef __cplusplus
}
#endif

#endif //(OS_QUE_EN==1)
#endif /* __OS_QUE_H__ */

